/**
 */
package usixmlcui.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import usixmlcui.ConcreteGraphicalCompoundIU;
import usixmlcui.ConcreteGraphicalElementaryIU;
import usixmlcui.Tab;
import usixmlcui.TabBar;
import usixmlcui.Usixml_cuiPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Tab</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link usixmlcui.impl.TabImpl#getText <em>Text</em>}</li>
 *   <li>{@link usixmlcui.impl.TabImpl#getIndex <em>Index</em>}</li>
 *   <li>{@link usixmlcui.impl.TabImpl#getEReference0 <em>EReference0</em>}</li>
 *   <li>{@link usixmlcui.impl.TabImpl#getEReference1 <em>EReference1</em>}</li>
 *   <li>{@link usixmlcui.impl.TabImpl#getEReference2 <em>EReference2</em>}</li>
 *   <li>{@link usixmlcui.impl.TabImpl#getEReference3 <em>EReference3</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TabImpl extends EObjectImpl implements Tab {
	/**
	 * The default value of the '{@link #getText() <em>Text</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getText()
	 * @generated
	 * @ordered
	 */
	protected static final String TEXT_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getText() <em>Text</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getText()
	 * @generated
	 * @ordered
	 */
	protected String text = TEXT_EDEFAULT;

	/**
	 * The default value of the '{@link #getIndex() <em>Index</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIndex()
	 * @generated
	 * @ordered
	 */
	protected static final int INDEX_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getIndex() <em>Index</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIndex()
	 * @generated
	 * @ordered
	 */
	protected int index = INDEX_EDEFAULT;

	/**
	 * The cached value of the '{@link #getEReference0() <em>EReference0</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEReference0()
	 * @generated
	 * @ordered
	 */
	protected ConcreteGraphicalCompoundIU eReference0;

	/**
	 * The cached value of the '{@link #getEReference1() <em>EReference1</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEReference1()
	 * @generated
	 * @ordered
	 */
	protected TabBar eReference1;

	/**
	 * The cached value of the '{@link #getEReference2() <em>EReference2</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEReference2()
	 * @generated
	 * @ordered
	 */
	protected ConcreteGraphicalElementaryIU eReference2;

	/**
	 * The cached value of the '{@link #getEReference3() <em>EReference3</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEReference3()
	 * @generated
	 * @ordered
	 */
	protected ConcreteGraphicalCompoundIU eReference3;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TabImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return Usixml_cuiPackage.Literals.TAB;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getText() {
		return text;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setText(String newText) {
		String oldText = text;
		text = newText;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.TAB__TEXT, oldText, text));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getIndex() {
		return index;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIndex(int newIndex) {
		int oldIndex = index;
		index = newIndex;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.TAB__INDEX, oldIndex, index));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ConcreteGraphicalCompoundIU getEReference0() {
		if (eReference0 != null && eReference0.eIsProxy()) {
			InternalEObject oldEReference0 = (InternalEObject)eReference0;
			eReference0 = (ConcreteGraphicalCompoundIU)eResolveProxy(oldEReference0);
			if (eReference0 != oldEReference0) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, Usixml_cuiPackage.TAB__EREFERENCE0, oldEReference0, eReference0));
			}
		}
		return eReference0;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ConcreteGraphicalCompoundIU basicGetEReference0() {
		return eReference0;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEReference0(ConcreteGraphicalCompoundIU newEReference0) {
		ConcreteGraphicalCompoundIU oldEReference0 = eReference0;
		eReference0 = newEReference0;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.TAB__EREFERENCE0, oldEReference0, eReference0));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TabBar getEReference1() {
		return eReference1;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetEReference1(TabBar newEReference1, NotificationChain msgs) {
		TabBar oldEReference1 = eReference1;
		eReference1 = newEReference1;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.TAB__EREFERENCE1, oldEReference1, newEReference1);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEReference1(TabBar newEReference1) {
		if (newEReference1 != eReference1) {
			NotificationChain msgs = null;
			if (eReference1 != null)
				msgs = ((InternalEObject)eReference1).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Usixml_cuiPackage.TAB__EREFERENCE1, null, msgs);
			if (newEReference1 != null)
				msgs = ((InternalEObject)newEReference1).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Usixml_cuiPackage.TAB__EREFERENCE1, null, msgs);
			msgs = basicSetEReference1(newEReference1, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.TAB__EREFERENCE1, newEReference1, newEReference1));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ConcreteGraphicalElementaryIU getEReference2() {
		if (eReference2 != null && eReference2.eIsProxy()) {
			InternalEObject oldEReference2 = (InternalEObject)eReference2;
			eReference2 = (ConcreteGraphicalElementaryIU)eResolveProxy(oldEReference2);
			if (eReference2 != oldEReference2) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, Usixml_cuiPackage.TAB__EREFERENCE2, oldEReference2, eReference2));
			}
		}
		return eReference2;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ConcreteGraphicalElementaryIU basicGetEReference2() {
		return eReference2;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEReference2(ConcreteGraphicalElementaryIU newEReference2) {
		ConcreteGraphicalElementaryIU oldEReference2 = eReference2;
		eReference2 = newEReference2;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.TAB__EREFERENCE2, oldEReference2, eReference2));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ConcreteGraphicalCompoundIU getEReference3() {
		if (eReference3 != null && eReference3.eIsProxy()) {
			InternalEObject oldEReference3 = (InternalEObject)eReference3;
			eReference3 = (ConcreteGraphicalCompoundIU)eResolveProxy(oldEReference3);
			if (eReference3 != oldEReference3) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, Usixml_cuiPackage.TAB__EREFERENCE3, oldEReference3, eReference3));
			}
		}
		return eReference3;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ConcreteGraphicalCompoundIU basicGetEReference3() {
		return eReference3;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetEReference3(ConcreteGraphicalCompoundIU newEReference3, NotificationChain msgs) {
		ConcreteGraphicalCompoundIU oldEReference3 = eReference3;
		eReference3 = newEReference3;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.TAB__EREFERENCE3, oldEReference3, newEReference3);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEReference3(ConcreteGraphicalCompoundIU newEReference3) {
		if (newEReference3 != eReference3) {
			NotificationChain msgs = null;
			if (eReference3 != null)
				msgs = ((InternalEObject)eReference3).eInverseRemove(this, Usixml_cuiPackage.CONCRETE_GRAPHICAL_COMPOUND_IU__EREFERENCE2, ConcreteGraphicalCompoundIU.class, msgs);
			if (newEReference3 != null)
				msgs = ((InternalEObject)newEReference3).eInverseAdd(this, Usixml_cuiPackage.CONCRETE_GRAPHICAL_COMPOUND_IU__EREFERENCE2, ConcreteGraphicalCompoundIU.class, msgs);
			msgs = basicSetEReference3(newEReference3, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.TAB__EREFERENCE3, newEReference3, newEReference3));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Usixml_cuiPackage.TAB__EREFERENCE3:
				if (eReference3 != null)
					msgs = ((InternalEObject)eReference3).eInverseRemove(this, Usixml_cuiPackage.CONCRETE_GRAPHICAL_COMPOUND_IU__EREFERENCE2, ConcreteGraphicalCompoundIU.class, msgs);
				return basicSetEReference3((ConcreteGraphicalCompoundIU)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Usixml_cuiPackage.TAB__EREFERENCE1:
				return basicSetEReference1(null, msgs);
			case Usixml_cuiPackage.TAB__EREFERENCE3:
				return basicSetEReference3(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Usixml_cuiPackage.TAB__TEXT:
				return getText();
			case Usixml_cuiPackage.TAB__INDEX:
				return new Integer(getIndex());
			case Usixml_cuiPackage.TAB__EREFERENCE0:
				if (resolve) return getEReference0();
				return basicGetEReference0();
			case Usixml_cuiPackage.TAB__EREFERENCE1:
				return getEReference1();
			case Usixml_cuiPackage.TAB__EREFERENCE2:
				if (resolve) return getEReference2();
				return basicGetEReference2();
			case Usixml_cuiPackage.TAB__EREFERENCE3:
				if (resolve) return getEReference3();
				return basicGetEReference3();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Usixml_cuiPackage.TAB__TEXT:
				setText((String)newValue);
				return;
			case Usixml_cuiPackage.TAB__INDEX:
				setIndex(((Integer)newValue).intValue());
				return;
			case Usixml_cuiPackage.TAB__EREFERENCE0:
				setEReference0((ConcreteGraphicalCompoundIU)newValue);
				return;
			case Usixml_cuiPackage.TAB__EREFERENCE1:
				setEReference1((TabBar)newValue);
				return;
			case Usixml_cuiPackage.TAB__EREFERENCE2:
				setEReference2((ConcreteGraphicalElementaryIU)newValue);
				return;
			case Usixml_cuiPackage.TAB__EREFERENCE3:
				setEReference3((ConcreteGraphicalCompoundIU)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID) {
			case Usixml_cuiPackage.TAB__TEXT:
				setText(TEXT_EDEFAULT);
				return;
			case Usixml_cuiPackage.TAB__INDEX:
				setIndex(INDEX_EDEFAULT);
				return;
			case Usixml_cuiPackage.TAB__EREFERENCE0:
				setEReference0((ConcreteGraphicalCompoundIU)null);
				return;
			case Usixml_cuiPackage.TAB__EREFERENCE1:
				setEReference1((TabBar)null);
				return;
			case Usixml_cuiPackage.TAB__EREFERENCE2:
				setEReference2((ConcreteGraphicalElementaryIU)null);
				return;
			case Usixml_cuiPackage.TAB__EREFERENCE3:
				setEReference3((ConcreteGraphicalCompoundIU)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Usixml_cuiPackage.TAB__TEXT:
				return TEXT_EDEFAULT == null ? text != null : !TEXT_EDEFAULT.equals(text);
			case Usixml_cuiPackage.TAB__INDEX:
				return index != INDEX_EDEFAULT;
			case Usixml_cuiPackage.TAB__EREFERENCE0:
				return eReference0 != null;
			case Usixml_cuiPackage.TAB__EREFERENCE1:
				return eReference1 != null;
			case Usixml_cuiPackage.TAB__EREFERENCE2:
				return eReference2 != null;
			case Usixml_cuiPackage.TAB__EREFERENCE3:
				return eReference3 != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (text: ");
		result.append(text);
		result.append(", index: ");
		result.append(index);
		result.append(')');
		return result.toString();
	}

} //TabImpl
